package reone.android.anytest.browserViewpagerTest;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;

import reone.android.anytest.R;
import reone.android.anytest.browserViewpagerTest.view.ViewsPagerBrowser;

public class BrowserViewPagerActivity extends ActionBarActivity {

    private ViewsPagerBrowser mViewPagerBrowser;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_browser_view_pager);
        mViewPagerBrowser = (ViewsPagerBrowser) findViewById(R.id.views_pager_browser);
        mViewPagerBrowser.setCanBecircle(true);
        ArrayList<View> views = getViews();
        mViewPagerBrowser.initOrUpdateViews(views);
        mViewPagerBrowser.setItemClickListner(new ViewsPagerBrowser.OnBrowserViewPagerItemClickListner(){

            @Override
            public void onItemClickListner(View itemview, int pos) {
                Toast.makeText(BrowserViewPagerActivity.this,"pos = " + pos +" text = " + ((TextView)itemview).getText(),Toast.LENGTH_SHORT).show();
            }
        });
    }


    private ArrayList<View> getViews(){
        ArrayList<View> views = new ArrayList<>();
        TextView tv1 = new TextView(this);
        tv1.setText("test1");
        views.add(tv1);
        TextView tv2 = new TextView(this);
        tv2.setText("test2");
        views.add(tv2);
        TextView tv3 = new TextView(this);
        tv3.setText("test3");
        views.add(tv3);
        return views;
    }
}
